home *** CD-ROM | disk | FTP | other *** search
- {$X+}
- uses crt, obined;
- var
- ed : edcb;
-
- const
- ExitCommands : array [1..9] of Char = #1#27#2#0#45#2#0#18#0;
-
- procedure EventHandler(EventNo, KbdFlagInfo : Word); far;
- const
- count : integer = 0;
- prev_lpos : integer = 0;
- var
- s : string;
- ch : char;
- lpos : integer;
- llen : integer;
- inins : boolean;
- begin
- if count > 0 then begin
- dec(count);
- exit;
- end;
- with CurrInternals^ do begin
- lpos := linepos;
- llen := linelen;
- str(llen:2, s);crtputfast(72, 25, calow+'Length '+s);
- str(ord(currchar):3, s);crtputfast(1, 25, calow+'Ascii '+s);
- if (llen > 70)
- and (lpos = llen+2)
- and (lpos = succ(prev_lpos)) then begin
- inins := (editoptions and edoptinsert) = edoptinsert;
- clearkbd;
- if not inins then
- stuffkey($5200);
- if llen > 78 then
- stuffkey($7300);
- stuffkey(ord(^M));
- if llen > 78 then begin
- stuffkey($7400);
- stuffkey(ord(' '));
- end;
- if not inins then
- stuffkey($5200);
- count := 7;
- end;
- prev_lpos := lpos;
- end;
- end;
-
- function confirm_abort : integer;
- var
- s : string;
- ch : char;
- begin
- s := caerr+'┌─────────────────────┐';crtputfast(29, 11, s);
- s := caerr+'│Enter - Confirm Abort│';crtputfast(29, 12, s);
- s := caerr+'│Esc - Resume Edit │';crtputfast(29, 13, s);
- s := caerr+'└─────────────────────┘';crtputfast(29, 14, s);
- repeat
- ch := readkey;
- if ch = #0 then readkey;
- until ch in [#13,#27];
- if ch = #13 then confirm_abort := -1 else confirm_abort := 0;
- end;
-
- procedure edit(fname : string);
- var
- result : integer;
- s : string;
- i,n : integer;
- allocsize : word;
- begin
- if maxavail > maxfilesize then
- allocsize := maxfilesize
- else
- allocsize := maxavail;
- ed.init(allocsize, 1, 1, 80, 24,
- true, edoptinsert, '.', exitcommands, @EventHandler);
- if ed.read(fname) > 1 then halt;
- ed.reset;
- s := 'Prodigy Computing (Pty) Limited - Small Editor';
- n := 80 - length(s);
- for i := 1 to n div 2 do
- insert(' ', s, 1);
- for n := length(s)+1 to 80 do
- s := s + ' ';
- crtputfast(1,25,calow+s);
- repeat
- result := ed.use('');
- case result of
- -1: begin
- ed.save(false);
- end;
- else begin
- if not ed.modified then
- result := -1
- else
- result := confirm_abort;
- end;
- end;
- until result = -1;
- end;
-
- begin
- if paramcount > 0 then
- edit(paramstr(1));
- clrscr;
- end.